//Purpose: Performs the Analysis for Crimes Against Morality
//This version: September 9, 2020; Jennifer Seager (jseagermuz@gwu.edu)

clear
clear matrix
estimates clear
cap log close
set more off

#delimit;
//directory set in file #0

*2. Setting Macros;
*2.1. Setting sample restrictions for DD;
*2.1.1. For the FSW Data;
local sw1 = "if sw==1&dataset==1&full==1";
	*still in sex work;
local sw2 = "if panel_v3==1&dataset==1";
	*in the panel and still in sex work;
local sw3 = "if panelsti_sept==1&dataset==1";
	*in the September STI panel.;
local sw4 = "if wspanel==1&dataset==1";

*2.1.2. For the FSW transaction data;
local tsw1 = "if dataset==2&full==1";
local tsw2 = "if panel_f==1 & dataset==2&full==1";

*2.1.3. For the Client Data;
local c1 = "if dataset==3";

*2.1.4. For the Client transaction data;
local tc1 = "if dataset==4";

*2.2. Setting controls;
local char = 
	"divwid unmarried edyrs age children sw_locyrs disc_factor risktol_nodl nodlr ";
local tchar1 = "regular outsider clean handsome old rich";
local tchar2 = "regular";
local cchar = "divwid unmarried edyrs age disc_factor risktol";
local tcchar = "regular clean attractive";

use "$da/Crimes-Against-Morality_Main_data-constructed.dta", clear;

***Table I: Summary Statistics;

eststo crim: mean married divwid unmarried edyrs age children sw_locyrs disc_factor 
				  hlthacc condeasy havecondom easyask  
				  if wave==1&dataset==1&closing==1, cluster(wsid);
eststo noncrim: mean married divwid unmarried edyrs age children sw_locyrs disc_factor 
				  hlthacc condeasy havecondom easyask 
				  if wave==1&dataset==1&closing==0, cluster(wsid);
				  
eststo crim1: mean risktol if wave==1&dataset==1&closing==1, cluster(wsid);
eststo noncrim1: mean risktol if wave==1&dataset==1&closing==0, cluster(wsid);
				  
eststo crim2: mean sept_any if wave==1&dataset==1&closing==1, cluster(wsid);
eststo noncrim2: mean sept_any if wave==1&dataset==1&closing==0, cluster(wsid);

eststo crim3: mean cndmpr if wave==1&dataset==1&closing==1, cluster(wsid);
eststo noncrim3: mean cndmpr if wave==1&dataset==1&closing==0, cluster(wsid);

eststo crim4: mean noco1_mean if wave==1&dataset==1&closing==1, cluster(wsid);
eststo noncrim4: mean noco1_mean if wave==1&dataset==1&closing==0, cluster(wsid);


eststo crim_cl: mean married divwid unmarried edyrs age disc_factor risktol 
				if wave==1&dataset==3&closing==1, cluster(wsid);
eststo noncrim_cl: mean married divwid unmarried edyrs age disc_factor risktol 
				   if wave==1&dataset==3&closing==0, cluster(wsid);
eststo crim_cl2: mean noco11 if wave==1&dataset==3&closing==1, cluster(wsid);
eststo noncrim_cl2: mean noco11 if wave==1&dataset==3&closing==0, cluster(wsid);

esttab crim noncrim
	using "$dout/Table_I.tex",
	collabels(none) obslast cells(b(fmt(3)) se(par fmt(3)))
	title("A. Female Sex Workers")
	labcol2("Married" "Divorced or Widowed" "Never Married" "Years of Education" 
			"Age" "Children" "Years at Location" "Discount Factor"
			"Biological Tests" "Health Exam" "Easy to Obtain" "Has Condom"
			"Easy to Ask" "Condom Price" "No Condom Used" "Sample Size")
	mlabels("Crim" "Non-Crim")
	replace nogaps nostar;
	
esttab crim2 noncrim2
	using "$dout/Table_I.tex",
	collabels(none) obslast cells(b(fmt(3)) se(par fmt(3)))
	labcol2("Biological Tests")
	mlabels("Crim" "Non-Crim") nonumbers
	append nogaps nostar noobs;
esttab crim3 noncrim3
	using "$dout/Table_I.tex",
	collabels(none) obslast cells(b(fmt(3)) se(par fmt(3)))
	labcol2("Condom Price")
	mlabels("Crim" "Non-Crim") nonumbers
	append nogaps nostar noobs;
esttab crim4 noncrim4
	using "$dout/Table_I.tex",
	collabels(none) obslast cells(b(fmt(3)) se(par fmt(3)))
	labcol2("No Condom Used")
	mlabels("Crim" "Non-Crim") nonumbers
	append nogaps nostar noobs;
esttab crim1 noncrim1
	using "$dout/Table_I.tex",
	collabels(none) obslast cells(b(fmt(3)) se(par fmt(3)))
	labcol2("Risk Tolerance")
	mlabels("Crim" "Non-Crim") nonumbers
	append nogaps nostar noobs;
esttab crim_cl noncrim_cl
	using "$dout/Table_I.tex",
	collabels(none) obslast cells(b(fmt(3)) se(par fmt(3)))
	title("B. Clients")
	labcol2("Married" "Divorced or Widowed" "Never Married" "Years of Education" 
			"Age" "Discount Factor" "Risk Tolerance" "No Condom Used" "Sample Size")
	mlabels("Crim" "Non-Crim")
	append nogaps nostar;
	
	esttab crim_cl2 noncrim_cl2
	using "$dout/Table_I.tex",
	collabels(none) obslast cells(b(fmt(3)) se(par fmt(3)))
	title("B. Clients")
	labcol2("No Condom Used" "Sample Size")
	mlabels("Crim" "Non-Crim")
	append nogaps nostar;
estimates clear; eststo clear;	
	
	
	local i=1;
foreach var in married divwid unmarried edyrs age children sw_locyrs disc_factor risktol 
				sept_any hlthacc condeasy havecondom easyask cndmpr noco1_mean{;

reg `var' closing if wave==1&dataset==1, cluster(wsid);
estimates store reg`i';
local i=`i'+1;
};
*;


esttab reg* using "$dout/Table_I.tex", 
			 cells(b(star fmt(3)) 
			 se(par fmt(3)) p(fmt(3)))
			 varwidth(14)
			 star(* 0.10 ** 0.05 *** 0.01)
			 title(Sex Worker Differences)
			 append;
estimates clear;
eststo clear;

	local i=1;
foreach var in married divwid unmarried edyrs age disc_factor risktol noco11 {;

reg `var' closing if wave==1&dataset==3, cluster(wsid);
estimates store reg`i';
local i=`i'+1;
};
*;

esttab reg* using "$dout/Table_I.tex", 
			 cells(b(star fmt(3)) 
			 se(par fmt(3)) p(fmt(3)))
			 varwidth(14)
			 star(* 0.10 ** 0.05 *** 0.01)
			 title(Client Differences)
			 append;
estimates clear;
eststo clear;

***Table II:Impact of Criminalization on Sex Worker Health and Condom Use;

*All Worksites;
#delimit;
areg sept_any 	dd_cl el if dataset==1, cluster(wsid) abs(wsid);
	sum sept_any if dataset==1&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=1;
	estadd scalar ind_fe=0;
	estimate store reg1;
areg hlthacc 	dd_cl el `char' `sw1'& condeasy!=., cluster(wsid) abs(wsid);
	sum hlthacc `sw1'& condeasy!=.&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=1;
	estadd scalar ind_fe=0;
	estimate store reg2;
areg cndom_index 	dd_cl el `char' `sw1', cluster(wsid) abs(wsid);
	sum cndom_index `sw1'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=1;
	estadd scalar ind_fe=0;
	estimate store reg_index;
areg condeasy 	dd_cl el `char' `sw1', cluster(wsid) abs(wsid);
	sum condeasy `sw1'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=1;
	estadd scalar ind_fe=0;
	estimate store reg3;
areg havecondom	dd_cl el `char' `sw1', cluster(wsid) abs(wsid);
	sum havecondom `sw1'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=1;
	estadd scalar ind_fe=0;
	estimate store reg4;
areg condomprice dd_cl el `char' `sw1', cluster(wsid) abs(wsid);
	sum cndmpr `sw1'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=1;
	estadd scalar ind_fe=0;
	estimate store reg5;
areg easyask dd_cl el `char' `sw1', cluster(wsid) abs(wsid);
	sum easyask `sw1'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=1;
	estadd scalar ind_fe=0;
	estimate store reg6;
areg noco1 		dd_cl el `tchar1' `tsw1', cluster(wsid) abs(fsw_fe);
	sum noco1 `tsw1'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=0;
	estadd scalar ind_fe=1;
	estimate store reg7;
areg noco1 		dd_cl el `tcchar' `tc1', cluster(wsid) abs(cl_fe);
	sum noco1 `tc1'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=0;
	estadd scalar ind_fe=1;
	estimate store reg8;

esttab reg1 reg2 reg_index reg3 reg4 reg5 reg6 reg7 reg8 using "$dout/Table_II.tex", 
			 cells(b(star fmt(3)) 
			 se(par fmt(3)))
			 varwidth(14)
			 star(* 0.10 ** 0.05 *** 0.01)
			 title(All Worksites)
			 keep(dd_cl el divwid unmarried edyrs age children 
				  sw_locyrs disc_factor risktol_nodl regular outsider clean 
				  handsome attractive old rich )
			 scalars(bl_crim ws_fe ind_fe)
			 replace;
estimates clear;
eststo clear;

*All Worksites, panel;
areg sept_any 	dd_cl el `sw3', cluster(wsid) abs(wsid);
	sum sept_any `sw3'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=1;
	estadd scalar ind_fe=0;
	estimate store reg1;
areg hlthacc 	dd_cl el `char' `sw2' &condeasy!=., cluster(wsid) abs(wsid);
	sum hlthacc `sw2'& condeasy!=.&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=1;
	estadd scalar ind_fe=0;
	estimate store reg2;
areg cndom_indexp 	dd_cl el `char' `sw2' , cluster(wsid) abs(wsid);
	sum cndom_indexp `sw2'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=1;
	estadd scalar ind_fe=0;
	estimate store reg_index;
areg condeasy 	dd_cl el `char' `sw2', cluster(wsid) abs(wsid);
	sum condeasy `sw2'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=1;
	estadd scalar ind_fe=0;
	estimate store reg3;
areg havecondom	dd_cl el `char' `sw2', cluster(wsid) abs(wsid);
	sum havecondom `sw2'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=1;
	estadd scalar ind_fe=0;
	estimate store reg4;
areg condomprice dd_cl el `char' `sw2', cluster(wsid) abs(wsid);
	sum cndmpr `sw2'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=1;
	estadd scalar ind_fe=0;
	estimate store reg5;
areg easyask dd_cl el `char' `sw2', cluster(wsid) abs(wsid);
	sum easyask `sw2'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=1;
	estadd scalar ind_fe=0;
	estimate store reg6;
areg noco1 		dd_cl el `tchar1' `tsw2', cluster(wsid) abs(fsw_fe);
	sum noco1 `tsw2'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
	estadd scalar ws_fe=0;
	estadd scalar ind_fe=1;
	estimate store reg7;

esttab reg1 reg2 reg_index reg3 reg4 reg5 reg6 reg7 using "$dout/Table_II.tex", 
			 cells(b(star fmt(3)) 
			 se(par fmt(3)))
			 varwidth(14)
			 star(* 0.10 ** 0.05 *** 0.01)
			 title(All Worksites, Panel Sample)
			 keep(dd_cl el divwid unmarried edyrs age children 
				  sw_locyrs disc_factor risktol_nodl regular outsider clean 
				  handsome old rich )
			 scalars(bl_crim ws_fe ind_fe)
			 append;
	
estimates clear;
eststo clear;
***Table III: Impact of Criminalization on Worksite Operations;

*All Worksites;
eststo: areg wrksite_index dd_cl el `char' `sw1', cluster(wsid) abs(wsid);
	sum wrksite_index `sw1'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
eststo: areg cl7day dd_cl el `char' `sw1', cluster(wsid) abs(wsid);
	sum cl7day `sw1'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
eststo: areg tr7day dd_cl el `char' `sw1', cluster(wsid) abs(wsid);
	sum tr7day `sw1'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
eststo: areg hr7day dd_cl el `char' `sw1', cluster(wsid) abs(wsid);
	sum hr7day `sw1'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
eststo: areg transprice dd_cl el `tchar1' `tsw1', cluster(wsid) abs(fsw_fe);
	sum price_trans `tsw1'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);
eststo: areg earn7day dd_cl el `char' `sw1', cluster(wsid) abs(wsid);
	sum ern7day `sw1'&el==0&closing==1;
	estadd scalar bl_crim=r(mean);

esttab using "$dout/Table_III.tex", 
			 cells(b(star fmt(3)) 
			 se(par fmt(3)))
			 varwidth(14)
			 star(* 0.10 ** 0.05 *** 0.01)
			 title(All Worksites)
			 keep(dd_cl el divwid unmarried edyrs age children 
				  sw_locyrs disc_factor risktol_nodl
				  regular outsider clean handsome old rich)
			 scalars(bl_crim r2 ar2)
			 replace;
	
estimates clear;
eststo clear;

*All Worksites, panel;
eststo: areg wrksite_indexp dd_cl el `char' `sw2', cluster(wsid) abs(wsid);
	sum wrksite_indexp `sw2' & el==0&closing==1;
	estadd scalar bl_crim=r(mean);
eststo: areg cl7day dd_cl el `char' `sw2', cluster(wsid) abs(wsid);
	sum cl7day `sw2' & el==0&closing==1;
	estadd scalar bl_crim=r(mean);
eststo: areg tr7day dd_cl el `char' `sw2', cluster(wsid) abs(wsid);
	sum tr7day `sw2' & el==0&closing==1;
	estadd scalar bl_crim=r(mean);
eststo: areg hr7day dd_cl el `char' `sw2', cluster(wsid) abs(wsid);
	sum hr7day `sw2' & el==0&closing==1;
	estadd scalar bl_crim=r(mean);
eststo: areg transprice dd_cl el `tchar1' `tsw2', cluster(wsid) abs(fsw_fe);
	sum price_trans `tsw2' & el==0&closing==1;
	estadd scalar bl_crim=r(mean);
eststo: areg earn7day dd_cl el `char' `sw2', cluster(wsid) abs(wsid);
	sum ern7day `sw2' & el==0&closing==1;
	estadd scalar bl_crim=r(mean);

esttab using "$dout/Table_III.tex", 
			 cells(b(star fmt(3)) 
			 se(par fmt(3)))
			 varwidth(14)
			 star(* 0.10 ** 0.05 *** 0.01)
			 title(All Worksites, panel)
			 keep(dd_cl el divwid unmarried edyrs age children 
				  sw_locyrs disc_factor risktol_nodl
				  regular outsider clean handsome old rich)
			 scalars(bl_crim r2 ar2)
			 append;
	
estimates clear;
eststo clear;

*CLIENTS All Worksites;
eststo: areg wrksitec_index dd_cl closing el `cchar' `c1', cluster(wsid) abs(ctypeid);
	sum wrksitec_index `c1' & el==0&closing==1;
	estadd scalar bl_crim=r(mean);
eststo: areg fsws2 dd_cl closing el `cchar' `c1', cluster(wsid) abs(ctypeid);
	sum fsws2 `c1' & el==0&closing==1;
	estadd scalar bl_crim=r(mean);
eststo: areg sextimes dd_cl closing el `cchar' `c1', cluster(wsid) abs(ctypeid);
	sum sextimes `c1' & el==0&closing==1;
	estadd scalar bl_crim=r(mean);
eststo: areg transprice dd_cl closing el `tcchar' `tc1', cluster(wsid) abs(cl_fe);
	sum price_trans `tc1' & el==0&closing==1;
	estadd scalar bl_crim=r(mean);
eststo: areg spend7day dd_cl closing el `cchar' `c1', cluster(wsid) abs(ctypeid);
	sum spnd7day `c1' & el==0&closing==1;
	estadd scalar bl_crim=r(mean);


esttab using "$dout/Table_III.tex", 
			 cells(b(star fmt(3)) 
			 se(par fmt(3)))
			 varwidth(14)
			 star(* 0.10 ** 0.05 *** 0.01)
			 title(All Worksites)
			 keep(dd_cl el divwid unmarried edyrs age disc_factor risktol
				  regular clean attractive)
			 scalars(bl_crim r2 ar2)
			 append;
	
estimates clear;
eststo clear;

***Table IV:Impact of Criminalization on Transaction, Sex Worker, and Client Characteristics;

*All Worksites;
foreach var in vag regular clean handsome outsider rich {;
eststo: areg `var' dd_cl el `tsw1', abs(fsw_fe) cluster(wsid);
	sum `var' `tsw1' & closing==1&el==0;
	estadd scalar bl_crim = r(mean);
};
*;
foreach var in unmarried edyrs age disc_factor risktol children {; 
eststo: areg `var' dd_cl el `sw1', abs(wsid) cluster(wsid);
	sum `var' `sw1' & closing==1&el==0;
	estadd scalar bl_crim = r(mean);
};

esttab using "$dout/Table_IV.tex", 
			 cells(b(star fmt(3)) 
			 se(par fmt(3)))
			 varwidth(14)
			 star(* 0.10 ** 0.05 *** 0.01)
			 title(All Worksites, FSW)
			 keep(dd_cl el)
			 scalars(bl_crim r2 ar2)
			 replace;
	
estimates clear;
eststo clear;

*All Worksites, panel;
foreach var in vag regular clean handsome outsider rich {;
eststo: areg `var' dd_cl el `tsw2', abs(fsw_fe) cluster(wsid);
	sum `var' `tsw2' & closing==1&el==0;
	estadd scalar bl_crim = r(mean);
};
*;
foreach var in unmarried edyrs age disc_factor risktol children {; 
eststo: areg `var' dd_cl el `sw2', abs(wsid) cluster(wsid);
	sum `var' `sw2' & closing==1&el==0;
	estadd scalar bl_crim = r(mean);
};

esttab using "$dout/Table_IV.tex", 
			 cells(b(star fmt(3)) 
			 se(par fmt(3)))
			 varwidth(14)
			 star(* 0.10 ** 0.05 *** 0.01)
			 title(All Worksites, FSW, panel)
			 keep(dd_cl el)
			 scalars(bl_crim r2 ar2)
			 append;
	
estimates clear;
eststo clear;


*Clients, all worksites;
foreach var in vag regular clean attractive {;
eststo: areg `var' dd_cl closing el `tc1', abs(cl_fe) cluster(wsid);
	sum `var' `tc1' & closing==1&el==0;
	estadd scalar bl_crim = r(mean);
};
*;
foreach var in unmarried edyrs age disc_factor risktol {; 
eststo: areg `var' dd_cl closing el `c1', abs(ctypeid) cluster(wsid);
	sum `var' `c1' & closing==1&el==0;
	estadd scalar bl_crim = r(mean);
};
*;
esttab using "$dout/Table_IV.tex", 
			 cells(b(star fmt(3)) 
			 se(par fmt(3)))
			 varwidth(14)
			 star(* 0.10 ** 0.05 *** 0.01)
			 title(Formal Worksites, clients)
			 keep(dd_cl el )
			 scalars(bl_crim r2 ar2)
			 append;
	
estimates clear;
eststo clear;
exit;
***Table V: Impact of Criminalization on Earnings, Well-being, and Children;


eststo: reg totalhours1 closing  if el==1,  cluster(wsid);
		sum totalhours1 if el==1&closing==0;
		estadd scalar el_nc = r(mean);
		sum totalhours1 if el==1&closing==1;
		estadd scalar el_c = r(mean);
eststo: reg earntotal	closing  if el==1,  cluster(wsid);
		sum earntotal if el==1&closing==0;
		estadd scalar el_nc = r(mean);
		sum earntotal if el==1&closing==1;
		estadd scalar el_c = r(mean);
eststo: reg lessade		closing  if el==1,  cluster(wsid);
		sum lessade if el==1&closing==0;
		estadd scalar el_nc = r(mean);
		sum lessade if el==1&closing==1;
		estadd scalar el_c = r(mean);
eststo: reg vunhappy	closing  if el==1,  cluster(wsid);
		sum vunhappy if el==1&closing==0;
		estadd scalar el_nc = r(mean);
		sum vunhappy if el==1&closing==1;
		estadd scalar el_c = r(mean);

esttab using "$dout/Table_V.tex", 
			 cells(b(star fmt(3)) 
			 se(par fmt(3)))
			 varwidth(14)
			 star(* 0.10 ** 0.05 *** 0.01)
			 title(All women, Endline Sample)
			 mtitles()
			 scalar(el_nc el_c)
			 replace;
			 estimates clear;
			 eststo clear;

eststo: reg totalhours1 closing  if el==1&sw==1,  cluster(wsid);
		sum totalhours1 if el==1&closing==0&sw==1;
		estadd scalar el_nc = r(mean);
		sum totalhours1 if el==1&closing==1&sw==1;
		estadd scalar el_c = r(mean);
eststo: reg earntotal	closing  if el==1&sw==1,  cluster(wsid);
		sum earntotal if el==1&closing==0&sw==1;
		estadd scalar el_nc = r(mean);
		sum earntotal if el==1&closing==1&sw==1;
		estadd scalar el_c = r(mean);
eststo: reg lessade		closing  if el==1&sw==1,  cluster(wsid);
		sum lessade if el==1&closing==0&sw==1;
		estadd scalar el_nc = r(mean);
		sum lessade if el==1&closing==1&sw==1;
		estadd scalar el_c = r(mean);
eststo: reg vunhappy	closing  if el==1&sw==1,  cluster(wsid);
		sum vunhappy if el==1&closing==0&sw==1;
		estadd scalar el_nc = r(mean);
		sum vunhappy if el==1&closing==1&sw==1;
		estadd scalar el_c = r(mean);


esttab using "$dout/Table_V.tex", 
			 cells(b(star fmt(3)) 
			 se(par fmt(3)))
			 varwidth(14)
			 star(* 0.10 ** 0.05 *** 0.01)
			 title(Sex Workers in Sex Work, Endline Sample)
			 mtitles()
			 scalar(el_nc el_c)
			 append;
			 estimates clear;
			 eststo clear;

eststo: reg totalhours1 closing  if el==1&sw==0,  cluster(wsid);
		sum totalhours1 if el==1&closing==0&sw==0;
		estadd scalar el_nc = r(mean);
		sum totalhours1 if el==1&closing==1&sw==0;
		estadd scalar el_c = r(mean);
eststo: reg earntotal	closing  if el==1&sw==0,  cluster(wsid);
		sum earntotal if el==1&closing==0&sw==0;
		estadd scalar el_nc = r(mean);
		sum earntotal if el==1&closing==1&sw==0;
		estadd scalar el_c = r(mean);
eststo: reg lessade		closing  if el==1&sw==0,  cluster(wsid);
		sum lessade if el==1&closing==0&sw==0;
		estadd scalar el_nc = r(mean);
		sum lessade if el==1&closing==1&sw==0;
		estadd scalar el_c = r(mean);
eststo: reg vunhappy	closing  if el==1&sw==0,  cluster(wsid);
		sum vunhappy if el==1&closing==0&sw==0;
		estadd scalar el_nc = r(mean);
		sum vunhappy if el==1&closing==1&sw==0;
		estadd scalar el_c = r(mean);

esttab using "$dout/Table_V.tex", 
			 cells(b(star fmt(3)) 
			 se(par fmt(3)))
			 varwidth(14)
			 star(* 0.10 ** 0.05 *** 0.01)
			 title(Sex Workers who left sex work, Endline Sample)
			 mtitles()
			 scalar(el_nc el_c)
			 append;
			 estimates clear;
			 eststo clear;


use "$da/Crimes-Against-Morality_Child_data-constructed.dta", clear;


foreach var in aff aff_do aff_schlcost aff_wrk {;

eststo: reg `var' closing if el==1&sw==1&male!=., cluster(wsid);
	sum `var' if el==1&closing==0&sw==1&male!=.;
	estadd scalar el_nc=r(mean);

};
*;

esttab using "$dout/Table_V.tex", 
			 cells(b(star fmt(3)) 
			 se(par fmt(3)))
			 varwidth(14)
			 star(* 0.10 ** 0.05 *** 0.01)
			 title(Sex Workers in Sex Work, Endline Sample)
			 mtitles()
			 scalar(el_nc)
			 append;
			 estimates clear;
			 eststo clear;

foreach var in aff aff_do aff_schlcost aff_wrk {;

eststo: reg `var' closing clos_male male if el==1&sw==1&male!=., cluster(wsid);
	sum `var' if el==1&closing==0&sw==1&male!=.&male==0;
	estadd scalar el_nc=r(mean);


};
*;

esttab using "$dout/Table_V.tex", 
			 cells(b(star fmt(3)) 
			 se(par fmt(3)))
			 varwidth(14)
			 star(* 0.10 ** 0.05 *** 0.01)
			 title(Sex Workers in Sex Work, Endline Sample)
			 mtitles()
			 scalar(el_nc)
			 append;
			 estimates clear;
			 eststo clear;

***Table VI: Impacts on General Population;

use "$da/Crimes-Against-Morality_General-Pop_data-constructed.dta", clear;

foreach out in groom_amt entertain_amt medical_amt_s sti_symptom {;
			  
			  reg `out' dd_crim crim i.wave if female==0, cluster(ea_2);
			  sum `out' if wave==1 & female==0;
			  estadd scalar mean = r(mean);
			  estimates store `out' ;
			  
			  };
			  
esttab groom_amt entertain_amt medical_amt_s sti_symptom
	using "$dout/Table_VI.tex",
	title("General Population Males") star(* 0.1 ** 0.05 *** 0.01)
	mtitles("=1 Spend on Grooming"
			"=1 Spend on Entertainment"
	        "=1 Spend on Medical for self"  
			"=1 STI symptom")
	cells(b(star fmt(3)) se(par fmt(3))) stats(mean N, fmt(3 0))
	nobaselevels noconstant style(tex) replace
	coeflabels(dd_crim "Crim $\times$ Endline"
			   crim "Crim" 2.wave "Endline");
			   

estimates clear;
eststo clear;


foreach out in groom_amt entertain_amt medical_amt_s sti_symptom {;
			  
			  reg `out' dd_crim crim i.wave if female==1, cluster(ea_2);
			  sum `out' if wave==1 & female==1;
			  estadd scalar mean = r(mean);
			  estimates store `out' ;
			  
			  };
			  
esttab groom_amt entertain_amt medical_amt_s sti_symptom
	using "$dout/Table_VI.tex",
	title("General Population Females") star(* 0.1 ** 0.05 *** 0.01)
	mtitles("=1 Spend on Grooming"
			"=1 Spend on Entertainment"
	        "=1 Spend on Medical for self"  
			"=1 STI symptom")
	cells(b(star fmt(3)) se(par fmt(3))) stats(mean N, fmt(3 0))
	nobaselevels noconstant style(tex) append
	coeflabels(dd_crim "Crim $\times$ Endline"
			   crim "Crim" 2.wave "Endline");
			   

estimates clear;
eststo clear;
